package com.zheng;

public class Demo1 {
    public static void main(String[] args) throws MyException {
        Mylsit m=new Mylsit();
      //  m.getInt(17);
        try{
            m.getInt(17);
        }catch (MyException e){
            System.out.println("在家长的监督下学习");
        }catch (MyRantimeException e){
            System.out.println("在子女的陪同下学习");
        }finally {
            System.out.println("finally");
        }
        System.out.println(m.age);
    }
}
class Mylsit{
    int age;
    public void getInt(int a) throws MyException {
        if (a<18){
            throw  new MyRantimeException("未满十八岁");
        }
        if (a>60){
            throw  new MyRantimeException("超过60岁");
        }
        this.age=a;
    }
}
class MyException extends Exception{
    public MyException() {
    }

    public MyException(String message) {
        super(message);
    }
}
class  MyRantimeException extends RuntimeException{
    public MyRantimeException() {
    }

    public MyRantimeException(String message) {
        super(message);
    }
}
